package com.xyb.controller;

import com.xyb.entity.Course;
import com.xyb.entity.CourseTopic;
import com.xyb.service.WebTopicService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("web/topic")
public class WebTopicController {
    @Resource
    private WebTopicService webTopicService;

    @GetMapping("/list")
    public List<CourseTopic> selectTopicList(){
        List<CourseTopic> list = webTopicService.selectTopicList();
        return list;
    }

    @GetMapping("/{topicId}")
    public CourseTopic selectCourseTopicByTopicId(@PathVariable("topicId") Long topicId){
        CourseTopic courseTopic = webTopicService.selectCourseTopicByTopicId(topicId);
        return courseTopic;
    }

    @GetMapping("/list/{topicId}")
    public List<Course> selectCourseListByTopicId(@PathVariable("topicId") Long topicId){
        List<Course> list = webTopicService.selectCourseListByTopicId(topicId);
        return list;
    }
}
